package thread.basepackage.t10;

/**
 * yield 放弃cpu资源 放弃的时间不确定，有可能刚放弃又获得了
 * Created by cuihao on 2017/11/29.
 */
public class MyThread extends Thread {
    @Override
    public void run() {
        long begionTime = System.currentTimeMillis();
        int count = 0;
        for (int i = 0; i < 500000; i++) {
            Thread.yield();
            count = count + (i + 1);
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - begionTime);
    }
}
